package com.wz.service.impl;

import com.github.pagehelper.PageHelper;
import com.wz.common.bean.PageBean;
import com.wz.common.bean.PageMap;
import com.wz.dao.DorderDao;
import com.wz.service.DorderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Map;
import java.util.UUID;

@Service
public class DorderServiceImpl implements DorderService {

	@Autowired
	DorderDao dorderDao;

	@Transactional
	@Override
	public int insert(Map map) {
		String uuid = UUID.randomUUID().toString();
		map.put("oid", uuid);
		//	map.put("id", uuid);
		int rs = dorderDao.insert(map);
		dorderDao.inserts(map);
		return rs;
	}

	@Override
	public PageBean query(Map map) {
		PageMap pageMap = new PageMap(map);
		PageHelper.startPage(pageMap.getPageNum(), pageMap.getPageSize());
		List list = dorderDao.query(pageMap);
		return new PageBean(list);
	}

	@Override
	public PageBean querypl(Map map) {
		PageMap pageMap = new PageMap(map);
		PageHelper.startPage(pageMap.getPageNum(), pageMap.getPageSize());
		List list = dorderDao.querypl(pageMap);
		return new PageBean(list);
	}

	@Override
	public int insertpl(Map map) {
		return dorderDao.insertpl(map);
	}
}
